package com.xpxrule.constant;

/**
 * @version 1.0
 * @Author xiangpengxiang
 * @Date 2024/11/20 16:48
 * @注释
 */
public enum Operator {
    NULL("null", "空值", "is null", "为空"),
    NOT_NULL("notNull", "非空值", "is not null", "不为空"),
    EQUAL("equal", "等于", "==", "等于"),
    NOT_EQUAL("notEqual", "不等于", "!=", "不等于"),
    GREATER_THAN("greaterThan", "大于", ">", "大于"),
    GREATER_THAN_OR_EQUAL("greaterThanOrEqual", "大于等于", ">=", "大于等于"),
    LESS_THAN("lessThan", "小于", "<", "小于"),
    LESS_THAN_OR_EQUAL("lessThanOrEqual", "小于等于", "<=", "小于等于"),
    BETWEEN("between", "介于", "between", "介于"),
    NOT_BETWEEN("notBetween", "不介于", "not between", "不介于"),
    CONTAINS("contains", "包含", "contains", "包含"),
    NOT_CONTAINS("notContains", "不包含", "not contains", "不包含"),
    IN("in", "包含于", "in", "属于"),
    NOT_IN("notIn", "不包含于", "not in", "不属于"),
    REGEX("regex", "正则匹配", "matches", ""),
    ;

    Operator(String code, String zhName, String aviatorExpression, String displayText) {
        this.code = code;
        this.zhName = zhName;
        this.aviatorExpression = aviatorExpression;
        this.displayText = displayText;
    }

    public static Operator getByCode(String code) {
        for (Operator operator : Operator.values()) {
            if (operator.getCode().equals(code)) {
                return operator;
            }
        }
        return null;
    }

    private final String code;
    private final String zhName;
    private final String aviatorExpression;
    private final String displayText;

    public String getCode() {
        return code;
    }

    public String getZhName() {
        return zhName;
    }

    public String getAviatorExpression() {
        return aviatorExpression;
    }

    public String getDisplayText() {
        return displayText;
    }
}
